home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / prog / asm_0_m.arj / HILOAD.DOC < prev    next >
Text File  |  1989-06-18  |  19KB  |  456 lines

  1.  
  2.                                  HILOAD
  3.  
  4.               An utility for loading TSR's someplace else
  5.                                    by
  6.                              Larry Shannon
  7.                               18 Jun 1989
  8.  
  9. HILOAD is a utility program designed to load your normal TSR 
  10. (Terminate-and-Stay-Resident) programs somewhere else in memory. Usually 
  11. this is a place outside the normal DOS region; that is, outside the 
  12. first 640K of system memory.
  13.  
  14. At this time, it does not include either extended or expanded memory.
  15.  
  16.  
  17.                                BACKGROUND
  18.  
  19. The 8088 used in the PC-XT is capable of addressing up to 1024K of 
  20. memory.  The designers of the PC and DOS decided that only the first 
  21. 640K would be used by the operating system, DOS, and the rest was 
  22. reserved for other uses.
  23.  
  24. Because of the way the 8088 forms addresses, it is customary to refer to 
  25. addresses by a segment:offset combination. The 'actual' final address is 
  26. formed by multiplying the segment value by 16 (i.e., shifting it left 4 
  27. places) and adding the result to the offset address.
  28.  
  29.         Thus, the very first address in the machine is called 0000:0000.
  30. An address 1024 bytes from this start (hex 400) may be variously
  31. indentified as 0000:0400, 0040:0000, 0020:0200, 0038:0080, etc.
  32.  
  33. For convenience, we may speak of the various segments as:
  34.  
  35.         0000:0000       to      0000:FFFF       Block 0
  36.         1000:0000       to      1000:FFFF       Block 1
  37.  
  38.                     and so on
  39.  
  40.         E000:0000       to      E000:FFFF       Block E
  41.         F000:0000       to      F000:FFFF       Block F
  42.  
  43. It is easy to see that there are 16 contiguous segments of 64K each, 
  44. yielding (16 X 64 =) 1024K, or one megabyte, and that DOS can only use 
  45. the first 10 segments, or blocks 0 through 9.
  46.  
  47. What is in the other 6 segments?  Is that 384K of potential memory just 
  48. sitting there idle?
  49.  
  50.  
  51.                            WHO'S USING WHAT?
  52.  
  53. Well, actually not. Some of these blocks have been set aside, and are 
  54. probably being used, for specific purposes.
  55.  
  56. Block F is where the ROM BIOS lives and, if you have a true- blue IBM 
  57. PC, where the ROM BASIC lives.  So the F block is pretty well spoken 
  58. for.
  59.  
  60. Block B is where the memory for the video sits.  If you have a 
  61. Monochrome Display Adapter (MDA), it uses 4K of memory at addresses 
  62. B000:0000 to B000:1000, and the remainder of the B block, 60K, is 
  63. unused. In fact, if you have a straight monochrome card like IBM 
  64. supplies, that's all the memory you have available.
  65.  
  66. If you have a Color Graphics Adapter (CGA), it occupies memory from 
  67. B800:0000 to B800:7FFF (or equivalently B000:8000 to B000:FFFF). Like 
  68. the MDA, when the CGA is in text mode it only uses the first 4K of this 
  69. memory, but it can support up to 8 'pages' of 4K each; when in graphics 
  70. mode, all 32K are in use. Like the MDA, true-blue CGA cards, and most 
  71. clone CGA cards, have only that 32K available.
  72.  
  73. Enhanced Graphics Adapters (EGA) are even bigger consumers of memory, at 
  74. maximum using the A block and part of the C block!
  75.  
  76. If you have a hard disk, its BIOS is normally located on the hard disk 
  77. controller card, and is ususlly resident at C000:8000, or as it is 
  78. commonly referred to, C800:0000.
  79.  
  80.  
  81.                                 SO WHAT?
  82.  
  83. Astute observers will notice that the D and E blocks were pretty much 
  84. left out of the above description.  It is believed that these areas of 
  85. memory were set aside by IBM for program cartridges, but few, if any, of 
  86. these were actually produced, and this area is normally wide open and 
  87. available for use.
  88.  
  89. If you are like most PC users, you have only a monochrome or CGA 
  90. display, and the A block is available to you also.
  91.  
  92.  
  93.                             DOWN TO BUSINESS
  94.  
  95. The '640K barrier' people talk about is caused by two reasons: programs 
  96. are getting more sophisticated and user-friendly, meaning they take up 
  97. more memory.  Secondly, there has been a proliferation of many handy 
  98. programs that reside in memory (TSR's) which 'pop up' with useful 
  99. information at the touch of a key or perform some other action.  
  100. Examples are SideKick from Borland International, various printer 
  101. buffers which are almost a necessity, and so on.  It is not too unusual 
  102. to have half one's DOS memory taken up with various TSR's.
  103.  
  104. While there's little we can do about fat programs, we can move these 
  105. TSR's out of the way. This was the driving force behind the development 
  106. of HILOAD.
  107.  
  108.                       WHERE DO I GET THIS MEMORY?
  109.  
  110. Some PC clone makers map their memory into the D and E blocks; Kaypro 
  111. for one does, others may also. Constructing a board to fill in these 
  112. holes is not difficult, especially if static RAMS (SRAM) are used; these 
  113. are now available in 32K X 8 sizes at attractive prices.
  114.  
  115. An old trick is to use commercial memory cards (now obsolete but 
  116. available) that allow themselves to be mapped into the desired regions.
  117.  
  118. Finally, users of Hercules Graphics cards and their clones usually have 
  119. the full 64K in the B block available, but only 4K is used in text mode.  
  120. That 60K looks mighty attractive, as does the 'spare' memory on a CGA 
  121. card...BUT...because one may easily forget there are programs in that 
  122. space, switching to Herc graphics, or simulating a CGA, or using a CGA 
  123. in graphics mode will really screw up the works, so this technique is 
  124. not recommended.  It may be used to test out the program, though, and 
  125. see if it's worth the small trouble to get memory for the 'safe' areas.
  126.  
  127.  
  128.                          HOW THE PROGRAM WORKS
  129.  
  130. HILOAD grabs the program you want, as well as any command tail required, 
  131. and loads it into the memory area you specify. After loading the 
  132. candidate TSR program, it revectors several DOS interrupts and then 
  133. executes the TSR program in the new location. When the TSR program 
  134. attempts to 'go resident', HILOAD traps that request, either from INT 
  135. 27H or function 31H of INT 21H, resets the appropriate interrupt 
  136. vectors, examines the interrupt vector table to see which ones point to 
  137. the new program, and then terminates normally.
  138.  
  139. Thus, when HILOAD exits, zero DOS memory is used up, and the TSR is 
  140. snugly nestled in another part of memory, acting just like it normally 
  141. does.
  142.  
  143.                      HOW TO SPECIFY VARIOUS THINGS
  144.  
  145. HILOAD requires various pieces of information to operate properly.
  146.  
  147. Addresses  -    HILOAD requires a starting address for 
  148.                 placing TSR's. After it places the first 
  149.                 one, it keeps track of where it should place 
  150.                 the next one by using the Intra-application 
  151.                 Communication Area (ICA) at 0040:00F0 
  152.                 through 0040:00FF. It checks this area and 
  153.                 computes an address from the information 
  154.                 there, so the initial starting address has 
  155.                 to be specified only once (until you change 
  156.                 blocks). As long as the loading area is 
  157.                 contiguous, the starting address need not be 
  158.                 re-specified.
  159.  
  160.                 The starting address is specified by an en- 
  161.                 vironment variable, which is discussed be- 
  162.                 low.
  163.  
  164. Program names - The program name to be loaded must be 
  165.                 specified with the full path name.  Sorry 
  166.                 about this, but it wasn't worth the effort 
  167.                 to program the logic to chase down the paths 
  168.                 to find the programs.  This is not consid-
  169.                 dered (by me, anyhow) to be a serious ob-
  170.                 jection, as the typical use of this program
  171.                 is in your AUTOEXEC file where it is only
  172.                 typed in once.
  173.  
  174. Starting off -  Executing HILOAD without any program 
  175.                 specified causes it to zero out the ICA.  
  176.                 This is the easiest way to begin a loading 
  177.                 sequence after changing the start address.
  178.  
  179.  
  180.            SPECIFYING A START ADDRESS (ENVIRONMENT VARIABLES)
  181.  
  182. When DOS loads a program, it also provides that program with a copy of 
  183. what it calls the Environment.  To see what the contents of your 
  184. environment are, do the following:
  185.  
  186.         At the DOS prompt (e.g., C:\>), type SET <CR>
  187.  
  188. The response will be a list of things, starting with COMSPEC and 
  189. continuing with your PATH and PROMPT values (if you have any).  After 
  190. these values, you may or may not have additional entries.  If you do, 
  191. they will be of the form:
  192.  
  193.         name=value
  194.  
  195. To add a value to the environment, type:
  196.  
  197.         set abc=ABCabc <CR>
  198.  
  199. and then type
  200.  
  201.         set <CR>
  202.  
  203. Notice that a new environment variable has been added.  Notice also that 
  204. the name, abc, has been capitalized as ABC, but the value remains as it 
  205. was typed in, i.e., ABCabc.
  206.  
  207. To change an environment value, type
  208.  
  209.         set name=NewValue<CR>
  210.  
  211. and NewValue will replace the old value.
  212.  
  213. To delete an environment variable, type
  214.  
  215.         set name=<CR>
  216.  
  217. and the value will disappear from the environment.
  218.  
  219. HILOAD requires an environment variable with a name the same as the 
  220. program name.  The value is the hex starting address.
  221.  
  222. So, if the program is named HILOAD, as it is on this disk, and the 
  223. desired starting value is A000, then you would set the environment 
  224. variable by typing:
  225.  
  226.         set hiload=A000<CR>
  227.  
  228. This can also be done as an entry in your AUTOEXEC.BAT file.
  229.  
  230. DOS is poorly documented, but it provides the name of the program it 
  231. loads, and where it came from, right after the environment.  I have used 
  232. this quirk of DOS to determine the name of the environment variable. If 
  233. you change the program name to, say, SHIFTSR.COM, then you would set the 
  234. environment variable as:
  235.  
  236.         set shiftsr=A000<CR>
  237.  
  238. This feature (?) allows you to have multiple copies of the program under 
  239. different names, each with its own environment variable, if you should 
  240. so desire.
  241.  
  242. NOTE:  As far as I can tell, this feature is only available in DOS 3.X.  
  243. The program determines the DOS version in use and, if less than 3.0, it 
  244. uses a default program name of HILOAD.  This is what the name of the 
  245. environment variable would have to be, no matter what you rename the 
  246. program to.
  247.  
  248.  
  249.                         INITIALIZING THE PROCESS
  250.  
  251. As stated above, the program must first initialize the ICA. It does this 
  252. by being invoked with no parameters.  The 'standard' starting sequence 
  253. is therefore:
  254.  
  255.         SET HILOAD=A000
  256.         HILOAD
  257.         etc.
  258.  
  259.  
  260.                       SPECIFYING PROGRAMS TO LOAD
  261.  
  262. Also as stated above, full path names must be given.  Suppose you have 
  263. four TSR's you wish to load, as follows:
  264.  
  265.  
  266.         NAME            SIZE            PARAMETERS (TSR command tail)
  267.  
  268.         TSR1             14K                 none
  269.         TSR2             22K                 /X /U /M=22
  270.         TSR3             1.4K                none
  271.         TSR4             26K                 'text string'
  272.  
  273. Adding them up, we see that they will occupy less than 64K, so they can 
  274. all be loaded in one block. Suppose also we have the A block available 
  275. for use.  The series of commands in the AUTOEXEC file to perform the 
  276. desired action might be:
  277.  
  278.  
  279.         SET HILOAD=A000                         starting address
  280.         HILOAD                                  initialize
  281.         HILOAD \DOS\TSR1                        load first tsr
  282.         HILOAD \SUB1\SUB2\TSR2 /X /U /M=22      load next tsr
  283.         HILOAD \TSR3                            load next tsr
  284.         HILOAD \UTILITY\TSR4 'text string'      load last tsr
  285.  
  286. The directories shown are the complete path names
  287. to the various TSR's.
  288.  
  289. Suppose now you have another TSR you want loaded, but it's too big to 
  290. fit in the A block; you have memory available in D block.
  291.  
  292. You would follow the above sequence with:
  293.  
  294.         SET HILOAD=D000                         reset start address
  295.         HILOAD                                  re-initialize
  296.         HILOAD \SUB3\SUB4\TSR5                  load it
  297.  
  298.  
  299.                              PROGRAM OUTPUT
  300.  
  301. HILOAD issues various progress and error messages as it chugs along. It 
  302. tells you the starting address it uses, the name of the program it is 
  303. loading, what it found for a command tail to the TSR, and the amount of 
  304. memory the TSR has reserved for itself.
  305.  
  306. It also lists the interrupts the TSR has captured, along with their new 
  307. addresses.  This can be handy for debugging purposes or just finding out 
  308. who captures what. Many TSRs do not go through Int 21H functions 35H and 
  309. 25H to get and set the interrupt vectors; they directly manipulate the 
  310. DOS interrupt table at the bottom of memory.  This is not a recommended 
  311. technique but many do so. HILOAD will capture these villians (SideKick 
  312. being the most prominent one) and show what they trap.
  313.  
  314. Incidentally, it appears that SideKick traps interrupt 21H for itself, 
  315. and any TSR loaded after it, who attempts to grab Int 9H, is pushed down 
  316. the list by SideKick so he (SideKick) still has first grab at the 
  317. keyboard. Very clever programming; a pain in the kazoo when you're 
  318. groping around to figure out what's actually happening!
  319.  
  320. The above comments are based on an older version of SideKick (1.56) 
  321. which I have been using. Later versions may act in a more civilized 
  322. manner.
  323.  
  324.  
  325.                            KEEPING THE OUTPUT
  326.  
  327. Since the information from HILOAD can whiz off the screen before you 
  328. have a chance to read it, it is a good idea to redirect the output to a 
  329. file instead of the screen.  The program output can then be perused at 
  330. your leisure. The following sequence is an example of how to do this:
  331.  
  332.  
  333.         DEL TSRLIST.LST                           delete old file
  334.         SET HILOAD=A000                           set start address
  335.         HILOAD >>TSRLST.LST                       initialize
  336.         HILOAD \TSR1 >>TSRLST.LST                 load first tsr
  337.         HILOAD \SUB1\TSR2 /X /Z >>TSRLST.LST      load next tsr
  338.         SET HILOAD=D000                           reset start address
  339.         HILOAD >>TSRLST.LST                       initialize
  340.         HILOAD \UTILITY\BIGTSR /PARMS >>TSRLST.LST  load big tsr
  341.  
  342. After everything is loaded, the file TSRLST.LST may be browsed to see 
  343. what went on, get addresses, check vectors, etc.
  344.  
  345. Of course, the output may also be redirected to the printer by putting a 
  346. >PRN instead of >>filename.ext
  347.  
  348.  
  349.                              ERROR MESSAGES
  350.  
  351. If something doesn't go right, the program tries to tell you and exit 
  352. safely.  The error messages are:
  353.  
  354.         No address given ... ABORTING          Something's wrong with the
  355.                                                environment variable. Check
  356.                                                spelling of variable name and
  357.                                                make sure it agrees with the
  358.                                                program name.
  359.                                                The value given must be 4 hex
  360.                                                digits, upper or lower case.
  361.  
  362.         Can't find file PROGNAME ... ABORTING   HILOAD was unable to locate
  363.                                                 the specified program. Check to
  364.                                                 see that the path is correct.
  365.                                                 Also, only .COM files can be
  366.                                                 loaded this way; .EXE files
  367.                                                 will bomb!
  368.  
  369.         Requires DOS 2.0 ... ABORTING           Program requires DOS version
  370.                                                 2.0 or above.
  371.  
  372.         The program also issues a message when it initializes the ICA.
  373.  
  374.  
  375.                                DISCLAIMER
  376.  
  377. TSRs are tricky things; SideKick is notorious for being sensitive to the 
  378. order in which other TSR's are loaded. Experiment with loading your TSRs 
  379. in the 'normal' fashion until you get a loading sequence that works. Use 
  380. that order to HILOAD them and all should be well.
  381.  
  382.  
  383.                               LEGAL STUFF
  384.  
  385. This program is being placed in the public domain.  It may be copied and 
  386. distributed freely for non-commercial uses.  Both this file and the 
  387. executable code must be distributed together and unmodified.
  388.  
  389. Any brand names mentioned are copyright by their respective owners.
  390.  
  391.  
  392.                            SHEEPISH ADMISSION
  393.  
  394.  
  395. This program was developed over a period of time as I was learning about 
  396. TSRs and revectoring interrupts, etc. Also, though the objective of the 
  397. program remained firm, the little niggly details kept changing on me as 
  398. I thought of alternate ways to accomplish things and more frills were 
  399. added.  
  400.  
  401. Consequently, the source code is comprehensible to me but I'm sure looks 
  402. like a real mess to the 'seasoned professional'.  I am thus a little 
  403. ashamed to release it for public scrutiny and scorn.
  404.  
  405. However, it is included and commented as best as I can recall what each 
  406. little piece does.  Don't bother to tell me there are 'dead code' areas 
  407. and unused variables.  
  408.  
  409. Anybody who wants can modify it to their hearts' content, but please 
  410. take note of the distributon restriction noted above.
  411.  
  412.  
  413.                           Larry Shannon 
  414.                           5615 Truscott Terrace
  415.                           Lakeview, NY  14085
  416.  
  417.                                 - end -
  418.  
  419.          ----------------end-of-author's-documentation---------------
  420.  
  421.                         Software Library Information:
  422.  
  423.                    This disk copy provided as a service of
  424.  
  425.                         The Public (Software) Library
  426.  
  427.          We are not the authors of this program, nor are we associated
  428.          with the author in any way other than as a distributor of the
  429.          program in accordance with the author's terms of distribution.
  430.  
  431.          Please direct shareware payments and specific questions about
  432.          this program to the author of the program, whose name appears
  433.          elsewhere in  this documentation. If you have trouble getting
  434.          in touch with the author,  we will do whatever we can to help
  435.          you with your questions. All programs have been tested and do
  436.          run.  To report problems,  please use the form that is in the
  437.          file PROBLEM.DOC on many of our disks or in other written for-
  438.          mat with screen printouts, if possible.  The P(s)L cannot de-
  439.          bug programs over the telephone.
  440.  
  441.          Disks in the P(s)L are updated monthly, so if you did not get
  442.          this disk  directly from the P(s)L,  you should be aware that
  443.          the files in this set may no  longer be the current versions.
  444.  
  445.          For a copy of the latest monthly software library newsletter
  446.          and a list of the 2,000+ disks in the library, call or write
  447.  
  448.                         The Public (Software) Library
  449.                               P.O.Box 35705 - F
  450.                            Houston, TX 77235-5705
  451.                             Orders: 800-2424-PSL
  452.                             Info:   713-524-6394
  453.                             FAX #:  713-524-6398
  454.                             CIS ID: 71355,470
  455.  
  456.